package sg.edu.nus.iss.vmcs.maintenance;

import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JLabel;

import sg.edu.nus.iss.vmcs.languagesupport.LanguageProperty;

public class LowQuantityNotifier extends Dialog{
	private Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
	private int frameX=0;
	private int frameY=0;
	private int frameWidth=200;
	private int frameHeight=100;
	private int screenWidth=screen.width;
	private int screenHeight=screen.height;

	private static final String TITLE = LanguageProperty.getLanguagerProperties().getProperty("notification.panel");
	private static final String CASHNOTI = LanguageProperty.getLanguagerProperties().getProperty("cash.out.of.stock");
	private static final String DRINKNOTI = LanguageProperty.getLanguagerProperties().getProperty("drink.out.of.stock");
	private static final Color WN_COLOR = Color.red;

	private static final long serialVersionUID = 1L;
	
	public LowQuantityNotifier(Dialog dl, String cashNoti, String drinksNoti) {
		super(dl, TITLE, false);
		// TODO Auto-generated constructor stub

		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent ev) {
				dispose();
			}
		});
		
		Panel tpn = new Panel();
		tpn.setLayout(new GridLayout(0, 1));
		
		if (!cashNoti.equals("")){
			JLabel lb1 = new JLabel(CASHNOTI);
			lb1.setFont(new Font("Helvetica", Font.BOLD, 24));
			
			JLabel lb2 = new JLabel(cashNoti);
			lb2.setForeground(WN_COLOR);
			
			tpn.add(lb1);
			tpn.add(lb2);
		}
		if (!drinksNoti.equals("")){
			JLabel lb3 = new JLabel(DRINKNOTI);
			lb3.setFont(new Font("Helvetica", Font.BOLD, 24));
			
			JLabel lb4 = new JLabel(drinksNoti);
			lb4.setForeground(WN_COLOR);

			tpn.add(lb3);
			tpn.add(lb4);
		}
		
		this.add(tpn);
		pack();
		frameWidth=this.getWidth();
        frameHeight=this.getHeight();
        frameX=(screenWidth-frameWidth);
        frameY=0;
        setBounds(frameX,frameY,frameWidth, frameHeight);
		
	}
	public void display() {
		this.setVisible(true);
	}

}
